package sparksql

import java.sql.DriverManager

/**
  * 通过jdbc方式编程
  */
object SparkSQLThriftserverApp {
  def main(args: Array[String]): Unit = {
    Class.forName("org.apache.hive.jdbc.HiveDriver");
    val conn = DriverManager.getConnection("jdbc:hive2://192.168.126.136:10000/lzc","root","");
    val pstmt = conn.prepareStatement("select * from user");
    val rs = pstmt.executeQuery();
    while(rs.next()) {
      println("id:" + rs.getInt("id") + " name:" + rs.getString("name"));
    }
    rs.close();
    pstmt.close();
    conn.close();
  }
}
